{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD4CAYAAADxeG0DAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAd5ElEQVR4nO3de3Ad1X0H8O/PikEWOICvHN6WDJiAH8QBJzT1TFNwAsRTMO+SSi4GGjW47cCUUkjkGZhmnKZ1poypMamTAfwaCJhhoK0zFAIZBiakyA3ExgxgsEVkKMhybeyR8Uu//nF2rdVqzz7u7r13997vZ+aOr/bu3XtYiZ+Ofud3zhFVBRERFdeYWjeAiIjSYSAnIio4BnIiooJjICciKjgGciKigvtcLT60tbVV29vba/HRRESFtWHDhh2qOtF/vCaBvL29HT09PbX4aCKiwhKR3qDjTK0QERUcAzkRUcExkBMRFVxNcuRBDh48iL6+Pnz22We1bgoBaG5uxmmnnYaxY8fWuilEFCE3gbyvrw/jx49He3s7RKTWzWloqoqBgQH09fVh8uTJtW4OEUXITWrls88+Q6lUYhDPARFBqVTiX0dEWVq7FmhvB8aMMf+uXZvZpXPTIwfAIJ4j/F4QZWjtWqCrCxgcNF/39pqvAaCjI/Xlc9MjJyKqW93dw0HcNThojmeAgdyjr68P8+bNw5QpU3DmmWfitttuw4EDBwLP/fDDD3HttddGXnPu3LnYtWtXWe2599578eMf/zjyvGOPPTb09V27dmH58uVltYGIyuRNpfQGzuMBPvggk48qbiDPON+kqrj66qtx5ZVX4t1338U777yDvXv3ojvgN+ahQ4dwyimnYN26dZHXXb9+PY4//vhUbUuLgZyoytxUSm8vELZ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nzC/xF/1XLvs+xXA9vMSdE6fiHwOwHEwP09x3lvJdkFEvgHzy/HrqrrfPW75nmYRmCLbpaoDni9/BjMm4r73j33v/VUGbYrVLo8bAPyV90AF71cctranvl9FTq28BmCKmIqLo2C+ac+oGT14ESY/DQA3Asiqh/+Mc7041x2Vm3OCmZuXvhJA4Oh2JdolIie4qQkRaQUwG8DmWt8v53v3FEzucJ3vtSzvV+DPS0h7rwXwgnN/ngFwg5iqlskApgD47xRtSdQuEfkygH8DcIWqfuI5Hvg9rWK7TvZ8eQWAt5znzwK4xGnfCQAuwci/TCvaLqdt58AMHP7ac6yS9yuOZwD8uVO98gcAdjudlfT3q1IjuGkeAK6CyRPtB/AxgGed46cAWO85by6Ad2B+o3Z7jp8B8z/aFgBPADg6o3aVAPwSwLsAngcwwTk+C8DPPOe1w/yWHeN7/wsANsIEpDUAjq1WuwD8ofPZbzj/3pKH+wWgE8BBAK97HjMrcb+Cfl5gUjVXOM+bnf/+Lc79OMPz3m7nfW8D+FbGP+9R7Xre+f/AvT/PRH1Pq9SufwTwpvP5LwI4x/Pem537uAXATdVsl/P1vQB+5Htfpe/XozBVVwdh4tctAL4L4LvO6wLgAafdG+GpyEt7vzhFn4io4IqcWiEiIjCQExEVHgM5EVHBMZATERUcAzkRUcExkBMRFRwDORFRwf0/nH6AhvXqSi8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "train_X = np.linspace(-1, 1, 100)\n",
    "train_Y = 2 * train_X + np.random.random(*train_X.shape) * 0.3\n",
    "\n",
    "## 显示模拟数据\n",
    "plt.plot(train_X, train_Y, 'ro', label='Original data')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 创建模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: Logging before flag parsing goes to stderr.\n",
      "W0804 13:33:33.643225 140261635254080 module_wrapper.py:136] From /usr/local/python3/lib/python3.6/site-packages/tensorflow_core/python/util/module_wrapper.py:163: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "## 占位符\n",
    "X = tf.placeholder('float')\n",
    "Y = tf.placeholder('float')\n",
    "\n",
    "## 模型参数初始化\n",
    "## tf.random_normal()函数用于从服从指定正太分布的数值中取出指定个数的值。\n",
    "## 初始化成[-1，1]的随机数\n",
    "## Variable：定义变量\n",
    "W =tf.Variable(tf.random_normal([1]), name=\"weight\")\n",
    "b =tf.Variable(tf.zeros([1]), name=\"bias\")\n",
    "\n",
    "## 前向结构\n",
    "## tf.multiply（）两个矩阵中对应元素各自相乘\n",
    "z = tf.multiply(X, W) + b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 反向结构"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "W0804 13:33:33.736763 140261635254080 module_wrapper.py:136] From /usr/local/python3/lib/python3.6/site-packages/tensorflow_core/python/util/module_wrapper.py:163: The name tf.train.GradientDescentOptimizer is deprecated. Please use tf.compat.v1.train.GradientDescentOptimizer instead.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "## reduce_mean计算张量的各个维度上的元素的平均值.\n",
    "cost = tf.reduce_mean(tf.square(Y - z))\n",
    "learning_rate = 0.01\n",
    "\n",
    "## 优化\n",
    "optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 迭代训练模型\n",
    "1.训练模型\n",
    "\n",
    "建立好模型后，可以通过迭代来训练模型了。TensorFlow中的任务是通过session来进行的。\n",
    "\n",
    "下面的代码中，先进行全局初始化，然后设置训练迭代的次数，启动session开始运行任务。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch: 1 cost= 1.1621948 W= [0.34350407] b= [0.628776]\n",
      "Epoch: 3 cost= 0.103357114 W= [1.5536253] b= [0.3230953]\n",
      "Epoch: 5 cost= 0.014590032 W= [1.8837897] b= [0.19906688]\n",
      "Epoch: 7 cost= 0.00868373 W= [1.9694496] b= [0.16624025]\n",
      "Epoch: 9 cost= 0.008319155 W= [1.9916037] b= [0.15773949]\n",
      "Epoch: 11 cost= 0.0083027175 W= [1.9973322] b= [0.1555412]\n",
      "Epoch: 13 cost= 0.008303675 W= [1.9988137] b= [0.1549727]\n",
      "Epoch: 15 cost= 0.008304267 W= [1.999196] b= [0.15482597]\n",
      "Epoch: 17 cost= 0.008304445 W= [1.9992955] b= [0.15478782]\n",
      "Epoch: 19 cost= 0.008304496 W= [1.9993222] b= [0.15477769]\n",
      " Finished!\n",
      "cost= 0.008304502 W= [1.9993261] b= [0.1547761]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD4CAYAAADxeG0DAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dd1zV5R7A8c8DMkQ0FfdgOHIrjrQ0c+CeaVkqmt6Gq3uzXYrbzMqWZg5apmJDvaZ265q5GtqQrubeYLiFRBBBxnP/+B30AOccDnKAc+D7fr14Ab/zG0+/Q9/z+H2+v+dRWmuEEEK4LreiboAQQoj8kUAuhBAuTgK5EEK4OAnkQgjh4iSQCyGEiytVFBetVKmSDgwMLIpLCyGEy4qMjLysta6cfXuRBPLAwEB2795dFJcWQgiXpZSKt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gq6PxuAocqoagkC6gO/5aMteWqXUqolsBQYoLW+aLbd4ntaiO2qbvbrAOCQ6edNQA9T+yoAPcj6L9MCbZepbQ0xBg53mW0ryPtljw3AI6bqlbuBeFNnJf/3q6BGcPPzBQzCyBOlABeATabtNYBvzPbrAxzF+EQNM9teB+N/tOPAasDLQe3yA7YAx4DvgYqm7W2AD832C8T4lHXLdvxWYB9GQFoJ+BZWu4D2pmvvNX1/zBnuFzACSAX2mH0FF8T9svT3gpGqGWD62dv033/cdD/qmB0bZjruCNDbwX/vubXre9P/B5n3Z0Nu72khtWsucMB0/W1AQ7NjHzXdx+PAPwqzXabfZwCvZTuuoO/XZxhVV6kY8esxYBwwzvS6At43tXsfZhV5+b1f8oi+EEK4OFdOrQghhEACuRBCuDwJ5EII4eIkkAshhIuTQC6EEC5OArkQQrg4CeRCCOHi/g8bMLAq3z5PZwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAACQCAYAAAAFk2ytAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAWzElEQVR4nO3deZgU5bXH8e9hBhAQBIUgCjoqrrkRhBHhJlGjhCCJYiKK4hXRIGau3BiXJOQaE8198sTEm8QdMoobQeNCNCS4Ae5G1MEAOmIQFCJeEHABlEVgzv3jrXaa7p6ZBqa7uqd/n+epZ6rrVHedLoo6Xdv7mrsjIiKlq1XcCYiISLxUCERESpwKgYhIiVMhEBEpcSoEIiIlToVARKTElcedwI7q2rWrV1RUxJ2GiEhRmTt37hp375YpVnSFoKKigpqamrjTEBEpKma2rKGYTg2JiJQ4FQIRkRJXMoVg6V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mtkiM5tqZoPN7IWoXf4B0Xyf/8KP5r3BzP5uZm8nfqFHn5X8RGav6Bf0W2b286RlPhw17lWbaODLzK4B2kXtwU+Npo2OGjWbb2ZTkj732NRlZ/hOC83s1mgZT5hZuyj2+S96M+tqZkuTvt/DFvorWGpm483sUjP7h5nNMbM9kxZxTpTn60nrp0PU+NrL0XuGJ33udDN7kvBQm5QwFQIpZL0JjYYdFg2jCE9kX07Dv9J7RPN8C2joSGEAcBpwJHB60imV8929P+HJ3u+b2V7uPgHY6O593f1sC62V/hQ4wUPDdckdCmWz7IOBm939i8DHUR5N+TdCmzRHA78ENrj7UcCLwOik+dq7e19Cfxu3R9OuIDShMgD4GnBt1FwBhDbyR7j7cVnkIC2YCoEUsnfc/TUPDYjVArM9PAr/GlDRwHsedvc6d3+DzM06Q2jf/wN33wj8mbDzhrDzTzQ90Yuw0051AvCAu68BcPfkduazWfY77p7ojWpuI98j2VPuvt7dVxOaTP9rND11Pdwb5fQs0MlCL2JDgAkWesB6mtC8yn7R/DNT8pcSpXODUsg2J43XJb2uo+FtN/k9DXU2lNquipvZ8YRGwAa5+wYze5qw09wR2Sw7eZ5tQLtofCv1P8xSl5vtekj7XlEep7n7P5MDZnYM8GkDOUqJ0RGBlKKvW+gvuB2hV7AXCE2RfxQVgcMI3W0mbLHQZDjAk4TTSXtB6He4mXJaCvSPxnf2wvZIADP7CqH117WElkr/K6nF1aN2MU9pgVQIpBS9TOgHYgEwzd1rgMeAcjNbSDi/Pydp/mpggZlNdfdawnn6Z6LTSBmbEN8J/wtUmdk/gJ3tH2FT9P5JhJY4Af4HaE3IvzZ6LbIdtT4qIlLidEQgIlLiVAhEREqcCoGISIlTIRARKXEqBCIiJU6FQESkxKkQiIiUOBUCEZES9/8ZUFKzJ4yN3AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#初始化所有变量\n",
    "init = tf.global_variables_initializer()\n",
    "#定义参数\n",
    "training_epochs = 20\n",
    "display_step = 2\n",
    "\n",
    "# 统计loss平均值\n",
    "def moving_average(a, w=10):\n",
    "    if len(a) < w: \n",
    "        return a[:]    \n",
    "    return [val if idx < w else sum(a[(idx-w):idx])/w for idx, val in \n",
    "    enumerate(a)]\n",
    "\n",
    "#启动session\n",
    "with tf.Session() as sess:\n",
    "    sess.run(init)\n",
    "    plotdata={\"batchsize\":[],\"loss\":[]} #存放批次值和损失值\n",
    "    #向模型输入数据\n",
    "    for epoch in range(training_epochs):\n",
    "        for (x, y) in zip(train_X, train_Y):\n",
    "            sess.run(optimizer, feed_dict={X: x, Y: y})\n",
    "\n",
    "        #显示训练中的详细信息\n",
    "        if epoch % display_step == 0:\n",
    "            loss = sess.run(cost,feed_dict={X:train_X,Y:train_Y})\n",
    "            print (\"Epoch:\", epoch+1,\"cost=\", loss,\"W=\",sess.run(W), \n",
    "            \"b=\", sess.run(b))\n",
    "            if not (loss == \"NA\" ):\n",
    "                plotdata[\"batchsize\"].append(epoch)\n",
    "                plotdata[\"loss\"].append(loss)\n",
    "\n",
    "    print (\" Finished!\")\n",
    "    print (\"cost=\", sess.run(cost, feed_dict={X: train_X, Y: train_Y}), \n",
    "    \"W=\", sess.run(W), \"b=\", sess.run(b))\n",
    "    \n",
    "    ## 显示拟合曲线\n",
    "    plt.plot(train_X, train_Y, 'ro', label = 'Original data')\n",
    "    plt.plot(train_X, sess.run(W) * train_X + sess.run(b), label='Fittedling')\n",
    "    plt.legend()\n",
    "    plt.show()\n",
    "\n",
    "    # 显示loss曲线\n",
    "    plotdata[\"avgloss\"] = moving_average(plotdata[\"loss\"])\n",
    "    plt.figure(1)\n",
    "    plt.subplot(211)\n",
    "    plt.plot(plotdata[\"batchsize\"], plotdata[\"avgloss\"],'b--')\n",
    "    plt.xlabel('minibatch number')\n",
    "    plt.ylabel('loss')\n",
    "    plt.title('')\n",
    "    plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
